<?php
    $query = " SELECT st_Segmento FROM tbl_SegmentosCRM ";
    $result = mssql_query ($query);
    $file = "";
    $time = time() - 86400;

    while ($row = mssql_fetch_object($result)){
      $file = $dir . "xls/" . html_entity_decode(urldecode($row->st_Segmento)) . ".xls";
      if ((file_exists($file)) and (filemtime($file) <= $time)){
        unlink ($file);
      }
    }
?>
